package com.sponsorpay.sdk.android.advertiser;

import android.content.Context;
import com.sponsorpay.sdk.android.SponsorPay;
import com.sponsorpay.sdk.android.credentials.SPCredentials;
import com.sponsorpay.sdk.android.utils.SPIdException;
import com.sponsorpay.sdk.android.utils.SPIdValidator;
import java.util.Map;

public class SponsorPayAdvertiser
{
  private static SponsorPayAdvertiser mInstance;
  private SponsorPayAdvertiserState mPersistedState;

  private SponsorPayAdvertiser(Context paramContext)
  {
    if (paramContext == null)
      throw new RuntimeException("The SDK was not initialized yet. You should call SponsorPay.start method");
    this.mPersistedState = new SponsorPayAdvertiserState(paramContext);
  }

  private static SponsorPayAdvertiser getInstance(Context paramContext)
  {
    if (mInstance == null)
      mInstance = new SponsorPayAdvertiser(paramContext);
    return mInstance;
  }

  private void notitfyActionCompletion(String paramString1, String paramString2, Map<String, String> paramMap)
  {
    ActionCallbackSender localActionCallbackSender = new ActionCallbackSender(paramString2, SponsorPay.getCredentials(paramString1), this.mPersistedState);
    localActionCallbackSender.setCustomParams(paramMap);
    localActionCallbackSender.trigger();
  }

  public static void register(Context paramContext)
  {
    register(paramContext, null);
  }

  public static void register(Context paramContext, Map<String, String> paramMap)
  {
    register(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramContext, paramMap);
  }

  public static void register(String paramString, Context paramContext, Map<String, String> paramMap)
  {
    getInstance(paramContext);
    mInstance.register(paramString, paramMap);
  }

  private void register(String paramString, Map<String, String> paramMap)
  {
    InstallCallbackSender localInstallCallbackSender = new InstallCallbackSender(SponsorPay.getCredentials(paramString), this.mPersistedState);
    localInstallCallbackSender.setCustomParams(paramMap);
    localInstallCallbackSender.trigger();
  }

  public static void reportActionCompletion(String paramString)
  {
    reportActionCompletion(SponsorPay.getCurrentCredentials().getCredentialsToken(), paramString);
  }

  public static void reportActionCompletion(String paramString1, String paramString2)
  {
    reportActionCompletion(paramString1, paramString2, null);
  }

  public static void reportActionCompletion(String paramString1, String paramString2, Map<String, String> paramMap)
  {
    try
    {
      SPIdValidator.validate(paramString2);
      if (mInstance == null)
        throw new RuntimeException("No valid credentials object was created yet.\nYou have to execute SponsorPay.start method first.");
    }
    catch (SPIdException localSPIdException)
    {
      throw new RuntimeException("The provided Action ID is not valid. " + localSPIdException.getLocalizedMessage());
    }
    mInstance.notitfyActionCompletion(paramString1, paramString2, paramMap);
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.sponsorpay.sdk.android.advertiser.SponsorPayAdvertiser
 * JD-Core Version:    0.6.2
 */